﻿#include <Sys\RenderUnit\SysRenderDatagram\TESTRD.HPP>
#include <Render\Render_Win32\Render_Win32_D3D\RENDER_WIN32_D3D9.HPP>
#include <Sys\RenderUnit\SYSDDCLASSID.HPP>
//#include <d3d9.h>
#include <d3dx9.h>


using namespace CxxlMan;
using namespace Cxxl3D;



class CTestDDD3D:public IDatagramDisposal_D3d9
{
  virtual bool cxxlFASTCALL Exec(const Smart_Ptr<IRenderDatagramDisposalCenterD3d> &IRenderDatagramDisposalCenterD3d_Arg,
    const Smart_Ptr<IRenderDatagram> &IRenderDatagram_Arg, LPDIRECT3DDEVICE9 pDEVICE9)
  {
    Smart_Ptr<ITestRD> ITestRD_Ptr = (ITestRD*)GetDefaultInterface(IRenderDatagram_Arg);
    Smart_Ptr<IC3D_Node> IC3D_Node_Ptr = ITestRD_Ptr->Get_IC3D_Node();
    CSmart_Ptr<const Matrix4x4> WorldMatrix_cPtr = IC3D_Node_Ptr->GetWorldMatrix();
    pDEVICE9->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)(const Matrix4x4*)WorldMatrix_cPtr); // Set world matrix

    unsigned int Count; 
    Vector4 *pVector4;

    pDEVICE9->SetRenderState( D3DRS_LIGHTING, FALSE );

    ITestRD_Ptr->GetData(&Count, &pVector4);

    pDEVICE9->BeginScene();
    pDEVICE9->SetFVF(D3DFVF_XYZ);
    pDEVICE9->DrawPrimitiveUP(D3DPT_LINELIST, Count, pVector4, sizeof(Vector4));
    pDEVICE9->EndScene();

    return true;
  }

public:

  // Constructor
  CTestDDD3D()
    :cxxlObject(Spirit_Easy)
  {
  }

  // Destructor
  virtual ~CTestDDD3D()
  {
  }


};


cxxlObject *cxxlFASTCALL New_CTestDDD3D()
{
  return new CTestDDD3D;
}